set :application, "media"
set :repository, "http://tecnophoto.googlecode.com/svn/trunk"

# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
# set :deploy_to, "/var/www/#{application}"
# 
set :deploy_to, "/home/tecnobrat/sites/media.tecnobrat.com" # defaults to "/u/apps/#{application}"
set :user, "tecnobrat"            # defaults to the currently logged in user
set :use_sudo, false
ssh_options[:paranoid] = false

# If you aren't using Subversion to manage your source code, specify
# your SCM below:
# set :scm, :subversion

role :web, "tecnobrat.com"
role :app, "tecnobrat.com"
role :db,  "tecnobrat.com", :primary => true

desc "link in production database credentials"
task :after_update_code do
  run <<-CMD
    ln -nfs #{deploy_to}/#{shared_dir}/config/database.yml #{release_path}/config/database.yml 
  CMD
  run <<-CMD
    ln -nfs #{deploy_to}/#{shared_dir}/image_files/ #{release_path}/public/image_files
  CMD
  run <<-CMD
    ln -nfs #{deploy_to}/#{shared_dir}/video_files/ #{release_path}/public/video_files
  CMD

  run "cd #{release_path} && RAILS_ENV=production rake db:migrate"
  run "cd #{release_path} && ruby script/backgroundrb stop"       
  run "cd #{release_path} && ruby script/backgroundrb start" 
end

task :after_restart do
  run "#{release_path}/script/process/reaper -a kill --dispatcher=/usr#{deploy_to}/current/public/dispatch.fcgi"
end

after :deploy, "deploy:cleanup"